<!--
 * @Author: your name
 * @Date: 2021-10-26 19:35:00
 * @LastEditTime: 2021-10-27 14:35:22
 * @LastEditors: Please set LastEditors
 * @Description: then后返回结果
 * @FilePath: \implement-promise-manually\src\index.html
-->
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./promise.js"></script>
</head>

<body>

</body>
<script>
    // let my = new MyPromise((resolve, reject) => {
    //        resolve("OK"); //-- 状态成功,结果为ok
    //     // reject("Error")   --状态失败。结果为error
    //     // throw "Error"     --状态失败。结果为error
    // });
    // const my1= my.then(res=>{
    //     return res+ "res2";
    // });
    // console.log(my1); // 返回普通值
    // let p1 = new Promise((resolve,reject) =>{
    //     resolve("OK")
    // })
    // let p2 = p1.then(res=>{
    //     return res + "res2";
    // })
    // console.log(p2);
    let p3 = new MyPromise((a,b)=>{
        b("firsst error");
    });
    const result = p3.then(res4=>{
        return new MyPromise((a,b)=>{
            a("okokok")
            // b("error")
        })
    });
    result.then(res=>{
        console.log(123);
    }).catch(err=>{
        console.log(err);
    })
    // console.log(result);
    // let p4 = new Promise((a,b)=>{
    //     a("errors");
    // });
    // const result2 = p4.then().catch(err=>err);
    // console.log(result2);
</script>

</html>